package com.ruoyi.web.controller.client.apply;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.ruoyi.framework.interceptor.LoginUser;
import com.ruoyi.framework.interceptor.MpAuthorize;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysProductApply;
import com.ruoyi.system.service.ISysProductApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品申请Controller
 */
@Api(tags = "产品申请")
@RestController
@RequestMapping("/client/apply")
public class SysProductApplyController extends BaseController
{
    @Autowired
    private ISysProductApplyService sysProductApplyService;

    /**
     * 查询产品申请列表
     */
    @MpAuthorize
    @GetMapping("/list")
    public TableDataInfo list(SysProductApply sysProductApply)
    {
        startPage();
        List<SysProductApply> list = sysProductApplyService.selectSysProductApplyList(sysProductApply);
        return getDataTable(list);
    }


    /**
     * 获取产品申请详细信息
     */
    @MpAuthorize
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysProductApplyService.selectSysProductApplyById(id));
    }

    /**
     * 新增产品申请
     */
    @MpAuthorize
    @Log(title = "产品申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid SysProductApply sysProductApply,@LoginUser Long userId)
    {
        return toAjax(sysProductApplyService.insertSysProductApply(sysProductApply,userId));
    }

}
